package leetcode;

import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * @Classname IntToRoman_0012
 * @Author happytaohaha
 * @Date 2020/4/1
 * @Description 12. 整数转罗马数字
 */
public class IntToRoman_0012 {


    public static String intToRoman(int num) {
        int[] nums = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String[] romans = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < nums.length;i++){
            while (num >=nums[i]){
                sb.append(romans[i]);
                num-=nums[i];
            }
        }
        return sb.toString();

    }

    public static void main(String[] args) {
        System.out.println(intToRoman(1994));
    }
}
